package com.yyaccp.appinfo.service;

import com.yyaccp.appinfo.domain.AppInfo;
import com.yyaccp.appinfo.mapper.AppInfoMapper;
import com.yyaccp.appinfo.utils.PageBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AppInfoService {

    @Autowired
    private AppInfoMapper appInfoMapper;

    public void search(AppInfo appInfo, PageBean pageBean) {
        int count = appInfoMapper.getCount(appInfo);
        pageBean.setCount(count);
        List<AppInfo> dataList = appInfoMapper.search(appInfo,((pageBean.getPageNum()-1)*pageBean.getPageSize()),pageBean.getPageSize());
        pageBean.setDataList(dataList);
    }

    public List<AppInfo> search(AppInfo appInfo) {
        return appInfoMapper.selectAll();
    }
    public Integer add(AppInfo appInfo) {
        return appInfoMapper.insert(appInfo);
    }

    public Integer upd(AppInfo appInfo) {
        return appInfoMapper.updateByPrimaryKey(appInfo);
    }


    public Integer yzName(String softwareName) {
        return appInfoMapper.yzName(softwareName);
    }

    public Integer yzAPK(String APKName) {
        return appInfoMapper.yzAPK(APKName);
    }

    public AppInfo getAppInfo(Long id) {
        return appInfoMapper.selectByPrimaryKey(id);
    }

    public int delById(Long id) {

        return appInfoMapper.deleteByPrimaryKey(id);
    }
}
